
package at.dcmspl;

import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Hannes Stornig, Gosch Daniel
 */
@Stateless
@LocalBean
public class FileNrProducer {
    @PersistenceContext EntityManager em;
    
    public long naechsteDateinummer() {
		FileCounter counter = em.find(FileCounter.class, FileCounter.ID);
		if (counter == null) {
			counter = new FileCounter();
			counter.setCounterstate(1000); // Initialer Zaehlerstand
			em.persist(counter);
		}
		counter.setCounterstate(counter.getCounterstate() + 1);
		return counter.getCounterstate();
	}
}
